import React, { Component } from 'react'
import ThemeContext from './context/theme-context'
import UserContext from './context/user-context'
export class HomeInfo extends Component {
  render() {
    // 获取 context
    console.log(this.context)
    const { color, size } = this.context;
    return (
      <div>
        HomeInfo
        <p>{color}-{size}</p>
        {/* 多个context */}
        <UserContext.Consumer>
          {
            value => {
              return <p>userContext -- {value.userName}</p>
            }
          }
          </UserContext.Consumer>
      </div>
    )
  }
}
// 指定contextType 之后，就可以通过this.context获取到共享的数据
HomeInfo.contextType = ThemeContext;

export default HomeInfo